<?php
	//Mang quyen cua NSD hien thoi
	$arrPermission = $_SESSION['arrStaffPermission'];
	//Lay id cua leftmenu hien hanh
	$leftmenuvisit = $this->sleftmenu;
	$arrleftmenuvisit = explode('_',$leftmenuvisit);
	$mmlv0 = 'mnl_'.$arrleftmenuvisit[1].'_0_0';
	$mmlv1 = 'mnl_'.$arrleftmenuvisit[1].'_'.$arrleftmenuvisit[2].'_0';
	$mmlv2 = 'mnl_'.$arrleftmenuvisit[1].'_'.$arrleftmenuvisit[2].'_'.$arrleftmenuvisit[3];
	$divlever0idvisit = 'divleft'.$arrleftmenuvisit[1].'_0';
	$divlever1idvisit = 'divleft'.$arrleftmenuvisit[1].'_'.$arrleftmenuvisit[2].'_0';
	$baseUrl = Efy_Init_Config::_getCurrentHttpAndHost();
?>
<div id="Iddiv_leftmenu"  style="background-color:#fff;">	
	<!-- thong tin nguoi dang nhap -->
	<div class="Info_user" ><?php echo $_SESSION['INFORMATION_STAFF_LOGIN'];?></div>
	<!--FullTextSearch-->	
	<div id ="Iddiv_FullTextSearch" class="body3" style="display:block;">
		<table width="98%" cellpadding="0"  cellspacing="0" class="search">	
			<tr>
				<td  class="">
				<input class="textboxsearch" type="textbox" name="FullTextSearchLeft" id="FullTextSearchLeft" value="<?=$this->sSearch;?>" onclick="addEnter();">
				</td>
	            <td>
	            <input class="buttonsearch" type="button" name="SearchFullTextSearch" id="SearchFullTextSearch" value="Tìm" onclick="checkvalue1();">
	            </td>
			</tr>
		</table>
	</div>
	<div id ="Iddiv_WebMenu">
		<table width="98%" cellpadding="0"  cellspacing="0" align="center"  class="left_menu_table">
			<?php
				$arrMenu = $this->arrMenu;
				//var_dump($arrMenu);
				$html = '';
				$iMenuLeve2Top = 0;
				for($i=0;$i<sizeof($arrMenu);$i++){
					$iDown = 0;
					$divID = '';
					if(($arrMenu[$i][C_POSITION]=='0')&&(($arrMenu[$i][C_PUBLIC_VIEW])||(strrpos('EFY'.$arrMenu[$i][FK_VIEW_STAFF_ID_LIST],$_SESSION['staff_id'])))){
						$MenuName = $arrMenu[$i][C_NAME];
						//Lay duong dan
						if(strrpos('EFY'.$arrMenu[$i][C_URL],"#DOWN#")){
							$iDown = 1;
							$arrMenu[$i][C_URL] = str_replace('#DOWN#','',$arrMenu[$i][C_URL]);
						}									
						if($arrMenu[$i][C_URL]==''){
							$urlRe = $baseUrl .'web/home/getarticle/?menuid='.$arrMenu[$i][PK_WEB_MENU].'&parent_menuid='.$arrMenu[$i][FK_WEB_MENU].'&articleid='.$arrMenu[$i][FK_WEB_ARTICLE];
						}else{
							if((substr_count($arrMenu[$i][C_URL],'http://')>0)||($arrMenu[$i][C_URL]=='#')){
								$urlRe = $arrMenu[$i][C_URL];
							}else{
								$urlRe = $baseUrl . $arrMenu[$i][C_URL];
								if(substr_count($urlRe,'?')>0){
										$urlRe = $urlRe.'&menuid='.$arrMenu[$i][PK_WEB_MENU].'&parent_menuid='.$arrMenu[$i][FK_WEB_MENU].'&articleid='.$arrMenu[$i][FK_WEB_ARTICLE];
								}else{
										$urlRe = $urlRe.'?menuid='.$arrMenu[$i][PK_WEB_MENU].'&parent_menuid='.$arrMenu[$i][FK_WEB_MENU].'&articleid='.$arrMenu[$i][FK_WEB_ARTICLE];
								}
							}		
						}	
						$sleftmenu = 'mnl_'.$arrMenu[$i][C_ORDER_LEVER1].'_'.$arrMenu[$i][C_ORDER_LEVER2].'_'.$arrMenu[$i][C_ORDER_LEVER3];	
						if(substr_count($urlRe,'?')>0){
								$urlRe = $urlRe.'&sleftmenu='.$sleftmenu;
						}else{
								$urlRe = $urlRe.'?sleftmenu='.$sleftmenu;
						}
						$iOpenNewWin = 0;
						if($arrMenu[$i][C_WINDOWS_OPEN]=='1'){
							$iOpenNewWin = 3;
						}
						//echo $urlRe;						
						if($arrMenu[$i][C_LEVEL]=='0'){
							if($iMenuLeve2Top == 1){
								$iMenuLeve2Top = 0;
								$html = $html.'</table></div></td></tr>';
							}
							if($iMenuLeve1Top == 1){
								$iMenuLeve1Top = 0;
								$html = $html.'</table></div></td></tr>';
							}	
							if($arrMenu[$i][CHECKPARENT] > 0){
								$iMenuLeve1Top = 1;
								//Neu $iDown cho so xuong
								if($iDown){
									$divID = 'divleft'.$arrMenu[$i][C_ORDER_LEVER1].'_'.$arrMenu[$i][C_ORDER_LEVER2];
									$divStyle = 'style="display:none;"';
									$urlRe = "javaScript:showHideMenu('".$divID."')";
								}else{
									$divStyle = 'style="display:block;"';
									$urlRe = "javaScript:goto_url('".$urlRe."',".$iOpenNewWin.")";
								}
								$html = $html.'<tr>';
								$html = $html.'<td id ="'.$sleftmenu.'" class="level0">';
								$html = $html.'<img src="'.$this->baseUrl. 'images/icon.png'.'" class="level0_img" />';
								$html = $html.'<a href="'.$urlRe.'">'.$MenuName.'</a>';																		
								$html = $html.'</td>';		
								$html = $html.'</tr>';	
								$html = $html.'<tr><td>';
								$html = $html.'<div id="'.$divID.'" '.$divStyle.' value="true">';
								$html = $html.'<table style="width:190px;"  class="" cellpadding="0" cellspacing="0">';
							}else{
								$urlRe = "javaScript:goto_url('".$urlRe."',".$iOpenNewWin.")";	
								$html = $html.'<tr>';
								$html = $html.'<td id ="'.$sleftmenu.'" class="level0">';
								$html = $html.'<img src="'.$this->baseUrl. 'images/button_menuc1_2.gif'.'" class="level0_img" />';
								$html = $html.'<a href="'.$urlRe.'">'.$MenuName.'</a>';																		
								$html = $html.'</td>';		
								$html = $html.'</tr>';
							}	
						}
						if($arrMenu[$i][C_LEVEL]=='1'){
							if($iMenuLeve2Top == 1){
								$iMenuLeve2Top = 0;
								$html = $html.'</table></div></td></tr>';
							}	
							$urlRe = "javaScript:goto_url('".$urlRe."',".$iOpenNewWin.")";	
							if($arrMenu[$i][CHECKPARENT] > 0){
								$iMenuLeve2Top = 1;
								$divID = 'divleft'.$arrMenu[$i][C_ORDER_LEVER1].'_'.$arrMenu[$i][C_ORDER_LEVER2].'_'.$arrMenu[$i][C_ORDER_LEVER3];
								//$urlRe = "javaScript:showHideMenu('".$divID."')";
								$html = $html.'<tr>';
								$html = $html.'<td id ="'.$sleftmenu.'" class="level1">';
								$html = $html.'<a href="'.$urlRe.'">'.$MenuName.'</a>';																		
								$html = $html.'</td>';		
								$html = $html.'</tr>';	
								$html = $html.'<tr><td>';
								$html = $html.'<div id="'.$divID.'" style="display:none;"  value="true">';
								$html = $html.'<table border="0" class="menu_level2" cellpadding="0" cellspacing="0">';
							}else{
								$html = $html.'<tr>';
								$html = $html.'<td id ="'.$sleftmenu.'" class="level1">';											
								$html = $html.'<a href="'.$urlRe.'">'.$MenuName.'</a>';																													
								$html = $html.'</td>';		
								$html = $html.'</tr>';	
							}
						}
						if($arrMenu[$i][C_LEVEL]=='2'){
							$html = $html.'<tr>';
							$html = $html.'<td id ="'.$sleftmenu.'" class="level2"><img src="'.$this->baseUrl.'images/icon_td_level2.gif">&nbsp;<a href="'.$urlRe.'">'.$MenuName.'</a></td>';																			
							$html = $html.'</tr>';				
						}
					}
				}
				if($iMenuLeve2Top == 1){
					$iMenuLeve2Top = 0;
					$html = $html.'</table></div></td></tr>';
				}
				if($iMenuLeve1Top == 1){
					$iMenuLeve1Top = 0;
					$html = $html.'</table></div></td></tr>';
				}
				//echo htmlspecialchars($html);//exit;
				echo $html;
			?>              
		</table> 		
	</div>	
</div>	
<table  width="100%" cellpadding="0"  cellspacing="0" border="0" style="background-color:#fff;">
		<tr>
			<td><a href="#" onclick="javascript:goto_url('http://www.chinhphu.vn/portal/page/portal/chinhphu/trangchu',3)" style="height:50px; width:190px; border:none;"><img style="height:50px; width:190px;border:none;" alt="Cong thong tin chinh phu" src="<? echo $this->baseUrl. 'images/cttchinhphu.jpg' ?>" /></a></td>
  		</tr>
		<tr>
			<td><a href="#" onclick="javascript:goto_url('http://haiphong.gov.vn/Portal/Default.aspx',3)" style="height:50px; width:190px; border:none;"><img style="height:50px; width:190px;border:none;" alt="Website thanh pho" src="<? echo $this->baseUrl. 'images/cttthanhpho.jpg' ?>" /></a></td>
  		</tr>
		<tr>
			<td><a href="#" onclick="javascript:goto_url('http://haiphong.gov.vn/Portal/Default.aspx?Organization=QHB',3)" style="height:50px; width:190px; border:none;"><img style="height:50px; width:190px;border:none;" alt="Website Quận" src="<? echo $this->baseUrl. 'images/ws-quan.gif' ?>" /></a></td>
  		</tr>
		<tr>
			<td><a href="<?=$baseUrl?>web/home/phone/?menuid=3C34EFF9-E60C-4B1F-BACF-90569BB1F006&parent_menuid=&articleid=&sliid=li8&sleftmenu=mn_0_0_0&srightmenu=mn_1_7_0" style="height:50px; width:190px;border:none;"><img style="height:50px; width:190px;border:none;" alt="Danh bạ điện thoại" src="<? echo $this->baseUrl. 'images/DB-dienthoai.jpg' ?>" /></a></td>
		</tr>
		<tr>
			<td>
				<a href="<?=$baseUrl?>web/home/viewarticle/?hdn_object_id=1B80E423-4946-42DF-BF07-EB09B1FE9092" style="height:50px; width:190px;border:none;">
					<img style="height:50px; width:190px;border:none; " alt="Hòm thư" src="<? echo $this->baseUrl. 'images/hom_thu.jpg'  ?> ">				</a>			</td>
		</tr>
</table>
<!--Xu ly JS!-->
<script type="text/javascript">
try {
	showHideMenu('<?=$divlever1idvisit?>');
	<? if($mmlv0 == $mmlv1){?>
			document.getElementById('<?=$mmlv0?>').className="level0_visited";
	<? }
	   if(($mmlv0 != $mmlv1)&&($mmlv1 == $mmlv2)){ ?>
	   		document.getElementById('<?=$mmlv0?>').className="level0_visited";
			document.getElementById('<?=$mmlv1?>').className="level1_visited";
	<? }
	   if(($mmlv0 != $mmlv1)&&($mmlv1 != $mmlv2)){ 
	?>
			document.getElementById('<?=$mmlv0?>').className="level0_visited";
			document.getElementById('<?=$mmlv1?>').className="level1_visited";
			document.getElementById('<?=$mmlv2?>').className="level2_visited";
	<? }?>
}catch(e){;}	

 function showHideMenu(p_id){		
	var objfrm = document.getElementsByTagName('div'); 
	for(i=0; i<objfrm.length; i++){
		e = objfrm[i].getAttribute('id'); 
		if (objfrm[i].getAttribute('value') == "true"){
	 		if(e == p_id){		
	 			var pStyle	= eval("document.getElementById('" + p_id + "').style.display");	 			
	 			if (pStyle == "none"){
	 				eval("document.getElementById('" + p_id + "').style.display = '" + "block'"); 
	 			}else{
	 				eval("document.getElementById('" + p_id + "').style.display = '" + "none'"); 
	 			}				 						 			
	 		}
 		}	
 	}
 } 
</script>
<script type="text/javascript">
	shortcut.add("Enter",function() {
		if(document.activeElement.name == 'FullTextSearchLeft'){
			checkvalue1();
		}else{
			var scriptFileName = '<?=$_SERVER['REQUEST_URI']?>';
			if(scriptFileName.search('index') >= 0){
				checkvalue();
			}else
				shortcut.remove("Enter");
		}
	});
	function addEnter(){
		shortcut.add("Enter",function() {
			if(document.activeElement.name == 'FullTextSearchLeft'){
				checkvalue1();
			}else{
				var scriptFileName = '<?=$_SERVER['REQUEST_URI']?>';
				if(scriptFileName.search('index') >= 0)
					checkvalue();
				else
					shortcut.remove("Enter");
			}
		});
	}
	function checkvalue1(){
		if(document.getElementById('FullTextSearchLeft').value != ''){
			var p_Url = '<?=$this->baseUrl?>' + '../web/home/search/?FullTextSearch=' + encodeURI(document.getElementById('FullTextSearchLeft').value);
			actionUrl(p_Url);
		}
	}
</script>